<template>
	<view class="content">
		<view class="uni-container statistics_bg">
			<view class="uni-flex uni-row" style="display: flex;flex-direction: row;justify-content: space-between;">
				<view class="text">成品入库</view>
			</view>
			<uni-table ref="table" border stripe>
				<uni-tr>
					<uni-th width="130" align="center">时间维度</uni-th>
					<uni-th width="30" align="center">总数量(件)</uni-th>
					<uni-th width="30" align="center">产值(元)</uni-th>
					<uni-th width="30" align="center">总成品重量(公斤)</uni-th>
					<uni-th width="30" align="center">产值/公斤</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData" :key="index">
					<uni-td align="center">{{ item.period }}</uni-td>
					<uni-td align="center">
						<view class="name">{{ item.in_stock_qty }}</view>
					</uni-td>
					<uni-td align="center">{{ item.in_stock_value }}</uni-td>
					<uni-td align="center">{{ item.in_stock_weight }}</uni-td>
					<uni-td align="center">{{ item.value_per_kg }}</uni-td>
				</uni-tr>
			</uni-table>

		</view>
		<view class="uni-container statistics_bg">
			<view class="uni-flex uni-row" style="display: flex;flex-direction: row;justify-content: space-between;">
				<view class="text">铸造</view>
			</view>
			<uni-table ref="table" border stripe>
				<uni-tr>
					<uni-th width="130" align="center">时间维度</uni-th>
					<uni-th align="center">总数量(件)</uni-th>
					<uni-th width="130" align="center">总铸件毛坯重量(公斤)</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData2" :key="index">
					<uni-td align="center">{{ item.period }}</uni-td>
					<uni-td align="center">
						<view class="name">{{ item.yz_qty }}</view>
					</uni-td>
					<uni-td align="center">{{ item.yz_weight }}</uni-td>
				</uni-tr>
			</uni-table>
		</view>
		
		<view class="uni-container statistics_bg">
			<view class="uni-flex uni-row" style="display: flex;flex-direction: row;justify-content: space-between;">
				<view class="text">清理</view>
			</view>
			<uni-table ref="table" border stripe>
				<uni-tr>
					<uni-th width="130" align="center">时间维度</uni-th>
					<uni-th align="center">总数量(件)</uni-th>
					<uni-th width="130" align="center">总重量(公斤)</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData2" :key="index">
					<uni-td align="center">{{ item.period }}</uni-td>
					<uni-td align="center">
						<view class="name">{{ item.ql_qty }}</view>
					</uni-td>
					<uni-td align="center">{{ item.ql_weight }}</uni-td>
				</uni-tr>
			</uni-table>
		</view>

    <view class="uni-container statistics_bg">
			<view class="uni-flex uni-row" style="display: flex;flex-direction: row;justify-content: space-between;">
				<view class="text">机加</view>
			</view>
			<uni-table ref="table" border stripe>
				<uni-tr>
					<uni-th width="130" align="center">时间维度</uni-th>
					<uni-th align="center">总数量(件)</uni-th>
					<uni-th width="130" align="center">总重量(公斤)</uni-th>
				</uni-tr>
				<uni-tr v-for="(item, index) in tableData2" :key="index">
					<uni-td align="center">{{ item.period }}</uni-td>
					<uni-td align="center">
						<view class="name">{{ item.jg_qty }}</view>
					</uni-td>
					<uni-td align="center">{{ item.jg_weight }}</uni-td>
				</uni-tr>
			</uni-table>
		</view>
		
		<view class="uni-container statistics_bg">
				<view class="uni-flex uni-row" style="display: flex;flex-direction: row;justify-content: space-between;">
					<view class="text">终检/包装</view>
				</view>
				<uni-table ref="table" border stripe>
					<uni-tr>
						<uni-th width="130" align="center">时间维度</uni-th>
						<uni-th align="center">总数量(件)</uni-th>
						<uni-th width="130" align="center">总重量(公斤)</uni-th>
					</uni-tr>
					<uni-tr v-for="(item, index) in tableData2" :key="index">
						<uni-td align="center">{{ item.period }}</uni-td>
						<uni-td align="center">
							<view class="name">{{ item.bz_qty }}</view>
						</uni-td>
						<uni-td align="center">{{ item.bz_weight }}</uni-td>
					</uni-tr>
				</uni-table>
			</view>
		
	</view>
</template>

<script>
	import {
		GetOperationsOverview
	} from '../../common/opsoverview_api.js'


	export default {
		data() {
			return {
				tableData: [],
				tableData2: [],
				opts: {

				}

			}
		},
		onReady() {

			uni.setNavigationBarTitle({
				title: "生产"
			})
			this.loadData();
		},



		methods: {
			loadData() {
				var data = {
					dimension_type: "生产",
					viewtype: "生产成品入库"
				};
				GetOperationsOverview(data).then(res => {
					var array = [];
					for (var i = 0; i < res.length; i++) {
						var item = res[i];
						array.push(item);
					}
					this.tableData = array;
				});
				var data2 = {
					dimension_type: "生产",
					viewtype: "生产工序汇总"
				};
				GetOperationsOverview(data2).then(res => {
					var array = [];
					for (var i = 0; i < res.length; i++) {
						var item = res[i];
						array.push(item);
					}
					this.tableData2 = array;
				});
			},


		},
	}
</script>

<style>
	@import url("prodstats.css");
</style>